<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .sd {
            position: absolute;
            width: 300px;
            height: 300px;
            background-color: pink;
        }
    </style>
</head>

<body>
    <div class="focus">

        <ul>
            <li><img src="upload/banner_1.png" alt=""></li>
            <li><img src="upload/banner_2.png" alt=""></li>
            <li><img src="upload/banner_3.png" alt=""></li>
            <li><img src="upload/banner_4.png" alt=""></li>
            <li><img src="upload/banner_5.png" alt=""></li>
            <li><img src="upload/banner_3.png" alt=""></li>
        </ul>
        <ol class="circle">
        </ol>
    </div>
    <script>
        window.addEventListener('load', function () {
            var arrow = document.querySelector('.arrow');
            var focus = document.querySelector('.focus');
            // 鼠标经过就显示隐藏
            focus.addEventListener('mouseenter', function () {
                arrow.style.display = 'block';
            });
            focus.addEventListener('mouseleave', function () {
                arrow.style.display = 'none';
            });
            //动态生成小圆圈
            var ul = focus.querySelector('ul');
            var ol = focus.querySelector('.circle');
            // 
            for (var i = 0; i < ul.children.length; i++) {
                var li = document.createElement('li');
                li.setAttribute('index', i);
                ol.appendChild(li);

                li.addEventListener('click', function () {
                    for (var i = 0; i < ol.children.length; i++) {
                        ol.children[i].className = '';
                    }
                    this.className = 'current';
                    var index = this.getAttribute('index');
                    // num = index;
                    // circle = index;
                    animate(ul, -focusWidth * index);
                })
            }
            ol.children[0].className = 'current';

        })
    </script>
</body>

</html>